package com.jl.obulibrary.servive;

import android.util.Log;

import com.jl.obulibrary.driver.LocalPsamSerialDriver;
import com.xfkj.etcpos.core.ETCPOS;
import com.xfkj.etcpos.core.exceps.CryptographyEngineException;

public class OperationByPsam {
    private static OperationByPsam instance;
    static  LocalPsamSerialDriver localPsamSerialDriver=           new LocalPsamSerialDriver();
    public static OperationByPsam getInstance() {
        if (instance == null) {
            instance = new OperationByPsam();
        }
        return instance;
    }
    public static void initEtcPsam() {
        //本地PSAM驱动
        ETCPOS.registerLocalPsamDriver(localPsamSerialDriver);
        localPsamSerialDriver.initPsamSlot();
    }


    public static String PsamApdu( String apdu) throws CryptographyEngineException {

        Log.e("Apdu",apdu);

        try {
            return  localPsamSerialDriver.psamChannelApdu(apdu);
        }catch ( Exception e){
            throw  new CryptographyEngineException("Apdu指令错误");
        }

    }
    public static void PsamReset() throws CryptographyEngineException {



        try {
               localPsamSerialDriver.psamReset();
        }catch ( Exception e){
            throw  new CryptographyEngineException("Apdu指令错误");
        }

    }
}
